package com.testmanager.testmananger.quantitative.mapper;

import com.testmanager.testmananger.quantitative.constants.DemandType;
import com.testmanager.testmananger.quantitative.domain.DemandInfoEntity;
import com.testmanager.testmananger.quantitative.dto.BugInfoDto;
import com.testmanager.testmananger.quantitative.dto.DemandInfoDto;
import com.testmanager.testmananger.quantitative.dto.WorkerDto;

public class DemandInfoMapper {

    public static DemandInfoDto toDemandInfoDto(DemandInfoEntity demandInfoEntity, WorkerDto workerDto){
        DemandInfoDto demandInfoDto = new DemandInfoDto();

        return demandInfoDto.setId(demandInfoEntity.getId())
                .setName(demandInfoEntity.getName())
                .setType(demandInfoEntity.getType().getValue())
                .setDemandNo(demandInfoEntity.getDemandNo())
                .setDemandURL(demandInfoEntity.getDemandURL())
                .setUiURL(demandInfoEntity.getUiURL())
                .setProtoTypeURL(demandInfoEntity.getProtoTypeURL())
                .setReviewDate(demandInfoEntity.getReviewDate())
                .setExtraMessage(demandInfoEntity.getExtraMessage())
                .setWorker(workerDto);
    }

    public static DemandInfoEntity toDemandInfoEntity(DemandInfoDto demandInfoDto,long iterationId){
        DemandInfoEntity demandInfoEntity = new DemandInfoEntity();
        return demandInfoEntity.setId(demandInfoDto.getId())
                .setIterationId(iterationId)
                .setName(demandInfoDto.getName())
                .setType(DemandType.getValueOf(demandInfoDto.getType()))
                .setDemandNo(demandInfoDto.getDemandNo())
                .setDemandURL(demandInfoDto.getDemandURL())
                .setUiURL(demandInfoDto.getUiURL())
                .setProtoTypeURL(demandInfoDto.getProtoTypeURL())
                .setReviewDate(demandInfoDto.getReviewDate())
                .setExtraMessage(demandInfoDto.getExtraMessage());
    }

}
